package initialize

import (
	"github.com/gin-gonic/gin"
	"yunwei/go_api/application/middleware"
	. "yunwei/go_api/application/router"
)

func InitRouter() *gin.Engine {
	// 创建路由
	router := gin.Default()
	// 处理跨域
	router.Use(middleware.Cors)
	// 添加日志
	router.Use(middleware.GinLogger())
	// 添加全局异常处理
	router.Use(middleware.ExceptionMiddleware)
	// 路由分组
	ApiGroup := router.Group("/api")
	InitUserRouter(ApiGroup)
	InitHostRouter(ApiGroup)
	InitCmdRouter(ApiGroup)
	InitTaskRouter(ApiGroup)
	return router
}
